Appendix B — Assignment B: Setting Up Your Course Workspace

Instructions

  1. The assignment is worth 100 points. See Canvas for the due date.

  2. You may discuss approaches with classmates, but write your own code and explanations and record evidence from your own computer. Put Python computations in Code cells and explanations and copied terminal evidence in Markdown cells.

  3. Recording terminal work. Whenever a question asks for a terminal command and its output, select the text in the VS Code terminal, copy it, and paste it into a Markdown cell inside a ```text block. Include the prompt line with the command, plus the output it printed. Do not use screenshots, and do not paste terminal commands into Python code cells. For long output, keep the lines the question asks about. For example:

    ```text
    (.venv) [username]@laptop stat303-1 % pwd
    /Users/[username]/stat303-1
    ```
  4. In this assignment you build the course folder that will hold every chapter practice kit and every assignment for the rest of the quarter, with one Python environment that all of them share. Download the Assignment B project kit; Question 1 tells you where to put it. Work in the supplied assignment_b.ipynb.

  5. This page contains the complete assignment instructions. The starter notebook contains numbered answer spaces and supplied demonstration code. Keep those sections in order and answer every numbered part below.

  6. Submit one file, assignment_b.html, to the Assignment B submission in Canvas. Keep the whole course folder on your computer, including its .venv, requirements.txt, and README.md; you will use it all quarter. Do not submit your .venv folder or the ZIP. You may replace your personal username in copied paths with [username], retaining enough detail to identify the project and environment.

  7. The data are fictional library-branch visit counts for one illustrative day. Pandas and plotting code are supplied in the notebook; you are assessing and explaining the workflow, not being asked to write unfamiliar analysis code.

  8. Five of the 100 points are for properly formatting the assignment. The breakdown is as follows:

    • A Quarto-rendered HTML file that opens with its table, plot, and final verification note (2 points).
    • Relevant, concise output without large extraneous printouts, such as full package-installation logs or printed environment listings (1 point). A kept %pip install seaborn cell that shows only Requirement already satisfied lines after a fresh run is acceptable.
    • Final written answers in Markdown (1 point).
    • No unnecessary/redundant code or text; required code runs in order (1 point).
  9. Generative AI. You may use generative AI tools (ChatGPT, Claude, GitHub Copilot, and similar) to understand concepts, interpret error messages, and debug code you have written. You may not use them to produce the code or written answers you submit. The test: you should be able to explain every line you submit and reproduce it without assistance. Disclose any use in the AI Use Disclosure section (Question 7). Honest disclosure earns points and carries no penalty on its own; undisclosed use is an academic integrity violation under the course syllabus.

When you finish, your course folder will look like this:

stat303-1/
├── .venv/                    ← the course environment (Question 2)
├── README.md                 ← your guide to this folder (Question 1)
├── requirements.txt          ← the environment's package record (Question 5)
├── assignments/
│   ├── assignment-a/         ← your completed Assignment A (no data needed)
│   │   ├── Assignment A.ipynb
│   │   └── Assignment A.html
│   └── assignment-b/         ← the extracted kit
│       ├── assignment_b.ipynb
│       ├── README.md
│       └── data/
│           └── library_visits.csv
└── chapters/
    └── stat303-setup/        ← moved here from Chapters 1–2
        ├── activity01.ipynb
        ├── activity02.ipynb
        ├── ...               (the other files you created there)
        └── data/
            └── station_readings.csv

From Chapter 3 on, each chapter’s practice kit goes in chapters/, and each assignment gets its own folder in assignments/, even when it has no data. You will always open stat303-1 in VS Code and use its one .venv.

Use the Chapter 1 Quarto refresher and Chapter 2 environment instructions as references. The Quarto VS Code extension is optional; the Quarto application performs rendering.

Points Summary

Section Points
1. Course folder 20
2. Environment 24
3. Packages 12
4. Navigation and paths 24
5. Dependencies 7
6. Supplied analysis interpretation 6
7. AI Use Disclosure 2
8. Formatting (instruction 8 above) 5
Total 100

1. Build and Organize the Course Folder (20 points)

Do these steps in order, using Finder on macOS or File Explorer on Windows to create, delete, and move folders. Close VS Code first, so that nothing is still using the Chapter 2 environment while you change its folder.

  1. Choose a location. Pick a place that cloud storage does not sync, such as your home folder. Avoid the iCloud-synced Desktop and Documents folders on macOS and OneDrive-synced folders on Windows: sync tools can upload, offload, or lock the thousands of small files inside .venv, and that breaks the environment.
  2. Create the folders. Create a folder named stat303-1, and inside it create two folders named chapters and assignments. Use these exact lowercase names, with no spaces.
  3. Retire the Chapter 2 environment. Inside your stat303-setup folder, delete the .venv folder. Keep everything else in stat303-setup, including your activity notebooks, HTML files, data, and requirements.txt.
  4. Move the Chapter 2 folder. Move stat303-setup into stat303-1/chapters/.
  5. Place the assignment kit. Extract the Assignment B ZIP and move the extracted assignment-b folder into stat303-1/assignments/. Check that you did not create a nested assignment-b/assignment-b/ folder.
  6. File Assignment A. Inside assignments, create a folder named assignment-a and move your completed Assignment A notebook and its rendered HTML into it. Assignment A has no data, but it still gets its own folder, so that every assignment follows the same rule and its notebook and rendered output stay together.
  7. Open the course folder. In VS Code, choose File → Open Folder and open stat303-1 itself, not assignments or assignment-b. From now on, this is the folder you open for every chapter and assignment.

1.1 Folder evidence (8 points)

Add your name to the notebook. Open a terminal in VS Code; it starts in stat303-1, the folder you opened. Show the current directory, then list the contents of stat303-1, chapters, and assignments without leaving stat303-1. To list a folder without entering it, put its name after the listing command: ls chapters on macOS, Get-ChildItem chapters in PowerShell, or dir chapters in Command Prompt. Copy the commands and output into your answer. State where you placed stat303-1 and why that location is not synced by cloud storage.

The root listing does not need .venv, README.md, or requirements.txt yet; you create them in later questions.

Credit: three listings showing the required structure, 5 points; location and reason, 2 points; name, 1 point.

1.2 Write a folder guide (6 points)

In VS Code’s Explorer, create a file named README.md directly inside stat303-1, next to chapters and assignments. Write a short guide, in your own words, that a classmate could follow to use the folder. It must say:

  • which folder to open in VS Code;
  • where the course environment and its requirements.txt live, and that .venv is never moved or copied;
  • where a new chapter practice kit goes;
  • where a new assignment goes, including one that has no data;
  • that each kit keeps its notebooks beside its own data/ folder when it has one.

Paste the text of your finished README.md into your answer inside a ```text block, so that it displays exactly as written.

Credit: five required points, 1 point each; clear, complete sentences, 1 point.

1.3 Explain the design (6 points)

Answer in your own words:

  1. Why does the course use one .venv at the root of stat303-1, instead of a separate environment inside each chapter kit?
  2. The Python venv documentation says that virtual environments are not movable or copyable, because an environment records the absolute location where it was created. Use this to explain why you deleted the Chapter 2 .venv instead of moving it along with stat303-setup. How will your Chapter 2 notebooks get a working environment now?
  3. Why does each kit keep its own data/ folder, instead of all kits sharing one data folder at the root of stat303-1? Consider the relative path Path("data") / "station_readings.csv" and the folder each notebook starts in.

Credit: three explanations, 2 points each.

2. Create and Verify the Course Environment (24 points)

This question builds the environment in three steps, in this order: create the course .venv, connect the notebook to it, and activate it in the terminal. Complete all three before you install any packages in Question 3, so that the notebook and the terminal both use the same Python.

2.1 The course environment (6 points)

Create a .venv directly inside stat303-1, using an existing appropriate Python installation. You may use either Chapter 2 method: the VS Code kernel picker (Create Python Environment → Venv) or the terminal command python -m venv .venv. Either method is acceptable, as long as the new .venv appears directly inside stat303-1, next to chapters and assignments, and not inside assignments, assignment-b, or a chapter kit. If you use the terminal, check that its current directory is stat303-1 before you run the command; if you use VS Code, check in Explorer where the folder appeared.

Record which existing Python you used and the creation method (VS Code or terminal). Explain why the course folder gets its own environment rather than reusing the one you used in STAT 201, and how that helps when another course needs different package versions.

Credit: creation method and source Python, 3 points; isolation explanation, 3 points.

2.2 Connect the notebook (8 points)

Open assignments/assignment-b/assignment_b.ipynb and use Select Kernel → Python Environments to choose the course .venv, the entry whose path contains stat303-1/.venv (or stat303-1\.venv on Windows). If VS Code prompts you to install ipykernel, accept the installation for this .venv; that package lets the environment run notebook cells. In the supplied notebook code cell, display the Python version, executable path, and current working directory.

Explain which part of the executable path identifies the course folder’s .venv. Many projects contain a folder named .venv, so point to the part of the path that shows this one belongs to stat303-1.

Credit: course kernel selected and notebook output, 5 points; executable-path interpretation, 3 points.

2.3 Activate the environment in the terminal (10 points)

Selecting a notebook kernel does not change which Python the terminal uses, so the terminal needs its own step. Use Python: Select Interpreter in the Command Palette to select the same course .venv for the workspace, then open a new VS Code terminal and make sure the environment is active: the prompt should begin with (.venv). If it does not, activate it with the command for your shell from Chapter 2.

Before installing any packages, answer the three questions: Where am I typing? Which Python am I using? Which folder is current? Record your shell, how the environment was activated (automatically by VS Code or with an activation command, and which one), and the commands and outputs identifying the Python executable and current directory.

Compare the terminal executable with the notebook executable from 2.2 and explain how you know both refer to the course environment. If they differ, fix the terminal activation or the notebook kernel and repeat the checks before moving on to Question 3.

Credit: shell and activation method, 2 points; three answers, 3 points; comparison with the notebook executable, 3 points; why the kernel choice alone does not set up the terminal, 2 points.

3. Install and Verify Packages (12 points)

3.1 Terminal installation (4 points)

In the VS Code terminal you activated in 2.3, confirm that the prompt still begins with (.venv), then install the course packages with the Chapter 2 command:

pip install ipykernel numpy pandas matplotlib

If VS Code already installed ipykernel when you connected the notebook in 2.2, pip reports Requirement already satisfied for it and installs the other three; that is expected. Record the command and its final lines of output. Explain why plain pip installs into the course environment here, and what you would check first if the prompt did not show (.venv).

Credit: command and output, 2 points; explanation, 2 points.

3.2 Notebook installation (3 points)

With the course .venv selected as the notebook kernel, install Seaborn by running %pip install seaborn in a notebook code cell. Restart the kernel if prompted. Record the command in Markdown and explain which environment it installs into.

Installation happens once: Seaborn is now stored in the course .venv, so every notebook that uses this environment can import it. If you run the same cell again, pip only reports Requirement already satisfied, so keeping the cell does no harm. It is cleaner to delete it, though, because the package is already in the environment and the cell would only add installation messages to your report on every fresh run.

Credit: command recorded in Markdown, 1 point; target environment, 2 points.

3.3 Verify the imports (5 points)

In a code cell, import NumPy, Pandas, Matplotlib, and Seaborn and print their version numbers. Explain your first diagnostic step if an installation succeeds in the terminal but the notebook cannot import the package.

Credit: four successful imports and version outputs, 3 points; diagnosis, 2 points. Package versions may differ across computers.

5. Record Dependencies (7 points)

With the terminal back in stat303-1 and using the course Python, export requirements.txt to the root of the course folder. Record the command and where the file was created. Open it, copy two actual package/version entries into Markdown, and explain what the file records. State one reason it does not guarantee identical behavior on every computer. Your Python version is already recorded in Question 2.

Credit: export command and location, 3 points; two entries and interpretation, 2 points; limitation, 2 points.

6. Interpret the Supplied Analysis (6 points)

Run the supplied data-reading and plotting cells. They display the six records, calculate the mean number of visits, and create a labeled bar chart. Keep their output in your report.

Explain what each axis represents and identify the branch with the most visits and the branch with the fewest. Explain why these fictional counts for one day do not establish a general pattern for real libraries.

Credit: axes, 2 points; largest and smallest branches, 2 points; limitation, 2 points. You do not need to rewrite the Pandas or plotting code.

7. AI Use Disclosure (2 points)

In the AI Use Disclosure section of your notebook, state whether generative AI tools were used to complete any part of this assignment.

  • If no AI was used, write: “I did not use generative AI tools on this assignment.”

  • If AI was used, you must specify:

    1. Tool(s) used (e.g., ChatGPT, GitHub Copilot, Claude, etc.)
    2. How they were used (e.g., explaining a concept, interpreting an error message, debugging a command you ran)
    3. Where they influenced your work (which questions/sections)
    4. Edits & verification you made (how you checked correctness, what you modified)

AI Use Template

  • Used AI? Yes / No
  • Tool(s):
  • Purpose / How used (1–3 sentences):
  • Scope (which questions/sections):
  • Edits & verification (what you changed and how you checked correctness):

Example (for illustration only): - Used AI? Yes - Tools: ChatGPT (free) - How used: Asked what (.venv) at the start of the terminal prompt means, and why Path(...).is_file() returned False for my first path. - Scope: 2.3, 4.3. - Edits & verification: Fixed the path myself by checking the notebook’s working directory; confirmed the check returned True and the three lines printed.

Grading (2 points): - 2 points = a clear statement that you did not use AI, or a complete, specific and honest disclosure (tools named, usage and verification described) - 1 point = a disclosure that is vague or missing required details - 0 points = no statement at all, or a disclosure that is misleading

Prepare and Submit the HTML

Restart the selected kernel, run all cells in order, resolve unexpected errors, and save. Record a brief fresh-run verification note. Render from the assignment folder. The terminal starts in stat303-1, so first move it there with cd assignments and then cd assignment-b, and check the current directory. Then run:

quarto render assignment_b.ipynb --to html

Open assignment_b.html, then copy the HTML alone into another folder and open that copy. Check that your explanations, code, table, and plot are visible. Add a short verification statement to the notebook, save, and render again so it appears in the final report. Upload the final HTML to Assignment B in Canvas.

This step is graded through the formatting points in instruction 8.